package com.ydx.demo.controller;

import com.ydx.demo.Dao.UserDao;
import com.ydx.demo.entity.ResponseData;
import com.ydx.demo.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/exception")
@RestController
public class ExceptionController {
    @GetMapping("/test1")
    public ResponseData test1(){
        int[] arr = {1,2,3};
        arr = null;
        System.out.println(arr[0]);
        Map<Integer, User> users = UserDao.findAllUsers();
        return new ResponseData ("200",null,true,users);
    }
    @GetMapping("/test2")
    public ResponseData test(){
        int[] arr = {1,2,3};
        System.out.println(arr[3]);
        Map<Integer, User> users = UserDao.findAllUsers();
        return new ResponseData("200",null,true,users);
    }
    @GetMapping("/test3")
    public ResponseData test3(){
        int[] arr = {1,2,3};
        int i = 10/0;
        Map<Integer, User> users = UserDao.findAllUsers();
        return new ResponseData("200",null,true,users);
    }
}
